//
//  NewsTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/3/2.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "NewsTableViewCell.h"

@interface NewsTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *theNewImage;

@end
@implementation NewsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self showBottomLineWithPaddingX:15 color:nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(NewsModel *)model {
    _model = model;
    
    self.titleLabel.text = model.title;
    self.timeLabel.text = [BMUtils chineseMMDDHHmmWithServiceTime:model.publish_time];
    
    NSDate *publishDate = [[model.publish_time substringToIndex:19] YJ_dateWithYYYYMMDDHHmmsss];
    if ([publishDate distanceInDaysToDate:[NSDate date]] <= 7) {
        NSMutableSet *newCacheSet = [[CacheTool sharedTool] objectForKey:Cache_IndustryNew_Scan_Key];
        
        self.theNewImage.hidden = [newCacheSet containsObject:model.newsid];
    }
    else {
        self.theNewImage.hidden = YES;
    }

}

- (void)setTheNewModel:(NewModel *)theNewModel {
    _theNewModel = theNewModel;

    self.titleLabel.text = theNewModel.title;
    self.timeLabel.text = [BMUtils chineseMMDDHHmmWithServiceTime:theNewModel.publish_time];
    
    NSDate *publishDate = [[theNewModel.publish_time substringToIndex:19] YJ_dateWithYYYYMMDDHHmmsss];
    if ([publishDate distanceInDaysToDate:[NSDate date]] <= 7) {
        NSMutableSet *newCacheSet = [[CacheTool sharedTool] objectForKey:Cache_IndustryNew_Scan_Key];
        self.theNewImage.hidden = [newCacheSet containsObject:theNewModel.newsid];
    }
    else {
        self.theNewImage.hidden = YES;
    }
}

- (void)setIsShowFooter:(BOOL)isShowFooter {
    _isShowFooter = isShowFooter;
    if (isShowFooter) {
        CGFloat height = 10.f;
        [self.bottomLine setFrame:CGRectMake(0, 75-height, SCREEN_WIDTH, height)];
    }
}

@end
